// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   MaxKindP.java

package include.nseer_cookie;

import include.nseer_db.nseer_db;
import include.tree_index.Nseer;
import java.sql.ResultSet;

public class MaxKindP
{

	private nseer_db db;
	private ResultSet rs;
	private String table_name;

	public MaxKindP(String dbase, String table, String fn, String human_id)
	{
		table_name = table;
		try
		{
			db = new nseer_db(dbase);
			String sql = (new StringBuilder("select * from ")).append(table).append(" where human_id='").append(human_id).append("' order by file_id").toString();
			rs = db.executeQuery(sql);
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}

	public MaxKindP(String dbase, String table, String fn)
	{
		table_name = table;
		try
		{
			db = new nseer_db(dbase);
			String sql = (new StringBuilder("select * from ")).append(table).append(" order by file_id").toString();
			rs = db.executeQuery(sql);
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}

	public String maxValue(String fv)
	{
		String value = "";
		try
		{
			Nseer n = new Nseer();
			while (rs.next()) 
				if (rs.getString(fv).length() > value.length())
					value = rs.getString(fv);
		}
		catch (Exception ex)
		{
			value = "0";
			ex.printStackTrace();
		}
		return value;
	}

	public static int getCount(String dbase)
	{
		int pre_control = 0;
		try
		{
			nseer_db erp_db = new nseer_db(dbase);
			String sql = "select type_name from erpplatform_config_public_char where kind='nseer_define'";
			ResultSet rs = erp_db.executeQuery(sql);
			if (rs.next())
				pre_control = Integer.parseInt(rs.getString("type_name").substring(2, 4)) - Integer.parseInt(rs.getString("type_name").substring(0, 2)) * 2;
			erp_db.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return pre_control;
	}

	public void close()
	{
		db.close();
	}
}
